package com.xc.h05.service.changlongfei.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xc.h05.entity.*;
import com.xc.h05.mapper.ConsultMapper;
import com.xc.h05.mapper.CourseMapper;
import com.xc.h05.mapper.CourseMapperCLF2;
import com.xc.h05.mapper.CoursetypeMapper;
import com.xc.h05.service.changlongfei.VCourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.List;
@Service
public class VCourseServiceImpl implements VCourseService {
    @Autowired
    private ConsultMapper consultMapper;
    @Autowired
    private CoursetypeMapper coursetypeMapper;
    @Autowired
    private CourseMapper courseMapper;
    @Autowired
    private CourseMapperCLF2 courseMapper1;
//        获取type分类
    @Override
    public List<Coursetype> getType() {
        return coursetypeMapper.selectAll2();
    }
//        获取咨询师表
    @Override
    public List<Consult> getConsult() {
        return consultMapper.findAll();
    }
//增加
    @Override
    public int addCourse(CourseCLF2 course) {
        return courseMapper1.insert(course);
    }
//删除
    @Override
    public int deleteCourse(Long id) {
        return courseMapper1.deleteByPrimaryKey(id);
    }
//修改
    @Override
    public int updateCourse(CourseCLF2 course) {
        return courseMapper1.updateByPrimaryKey(course);
    }
//查询

    public PageInfo<CourseCLFV>  getCourseByPage(int pageNum, int pageSize,CourseCLFV courseCLFV){
        PageHelper.startPage(pageNum,pageSize);
        List<CourseCLFV> courseCLFVS = courseMapper.selectCourseByPage(courseCLFV);
        return new PageInfo<>(courseCLFVS);

    }
// 批量删除
    @Override
    public int deleteCourseBatch(List<Long> ids) {
        return courseMapper.deleteCourseBatch(ids);
    }



}
